package com.zyl.blog.common.enums;

import lombok.Getter;

/**
 * @version v1.0
 * @ProjectName: Personal_Blog
 * @Package: com.zyl.common.core.enums
 * @ClassName: OperationType
 * @Description: 操作管理枚举
 * @Author FinalFantasy
 * @Date 2025/2/17-17:57
 */
@Getter
public enum OperationType {
    MANAGE("管理", 0),
    CREATE("新增", 1),
    DELETE("删除", 2),
    UPDATE("修改", 3),
    QUERY("查询", 4),
    IMPORT("导入", 5),
    EXPORT("导出", 6),
    LOGIN("登录", 7),
    REGISTER("注册", 8),
    LOGOUT("登出", 9),
    UPLOAD("上传", 10),
    DOWNLOAD("下载", 11),
    CHAT("聊天", 12),
    AI_MODELS("AI模型", 13),
    TEST("测试", 14);


    private final String desc;
    private final int code;

    OperationType(String desc, int code) {
        this.desc = desc;
        this.code = code;
    }

    /**
     * 根据code值获取枚举实例
     */
    public static OperationType fromCode(int code) {
        for (OperationType type : values()) {
            if (type.code == code) {
                return type;
            }
        }
        throw new IllegalArgumentException("无效的操作类型代码: " + code);
    }
}